const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('lib_book_reviews', {
    rating: {
      type: DataTypes.INTEGER,
      allowNull: true
    },
    user_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      references: {
        model: 'lib_users',
        key: 'user_id'
      }
    },
    book_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      references: {
        model: 'lib_books',
        key: 'book_id'
      }
    },
    review_id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    content: {
      type: DataTypes.TEXT,
      allowNull: true
    }
  }, {
    sequelize,
    tableName: 'lib_book_reviews',
    schema: 'library',
    timestamps: false,
    indexes: [
      {
        name: "lib_book_reviews_pkey",
        unique: true,
        fields: [
          { name: "review_id" },
        ]
      },
    ]
  });
};
